package data
{
	import flash.net.SharedObject;
	/**
	 * Сохраняем пройденные уровни в shared дате
	 * // see here for more: http://as3coder.blogspot.ru/2010/08/sharedobject.html
	 * @author yaempechenki@gmail.com
	 */
	public class SharedData 
	{
		private const SHARED_DATA_NAME:String = "zong-radio.ru";
		public static const VOLUME_LEVEL:String = "volume_level";
		
		public function SharedData() 
		{
			//clear();
		}
		
		public function save(key:String, value:String):void {
			var so:SharedObject = SharedObject.getLocal(SHARED_DATA_NAME);
			so.data[key] = value;
			so.flush();
		}
		
		public function load(key:String):String {
			var so:SharedObject = SharedObject.getLocal(SHARED_DATA_NAME);
			return doValid(so.data[key]);
		}
		
		private function doValid(value:String):String {
			if (value) {
				return value;
			}
			return "";
		}
		
		private function clear():void {
			var so:SharedObject = SharedObject.getLocal(SHARED_DATA_NAME);
			so.clear();
		}
		
	}

}